home *** CD-ROM | disk | FTP | other *** search
- /*
- * Modified by Phill Everson <everson@cs.bris.ac.uk> 29th May, 1989 for
- * inclusion into the ALV toolkit.
- *
- */
-
- /**************************************************************************
- The program "scload" is like Sun's "screenload" program, but more
- entertaining, and actually better than screenload.
-
- Copyright (c) 1988 by Raymond Kreisel
- 7/1/88 @ Suny Stony Brook
-
- This program may be redistributed without fee as long as this copyright
- notice is intact.
-
- ==> PLEASE send comments and bug reports to one of the following addresses:
-
- Ray Kreisel
- CS Dept., SUNY at Stony Brook, Stony Brook NY 11794
-
- UUCP: {allegra, philabs, pyramid, research}!sbcs!rayk
- ARPA-Internet: rayk@sbcs.sunysb.edu
- CSnet: rayk@suny-sb
- (If nobody is home at any of the above addresses try:
- S72QKRE@TOWSONVX.BITNET )
-
- "If I get home before daylight, I just might get some sleep tonight...."
-
- **************************************************************************/
- #include <pixrect/pixrect_hs.h>
- #include <stdio.h>
- #include <sys/time.h>
- #include <sys/types.h>
- #include <sys/stat.h>
-
- #include "defs.h"
-
- har *progname;
- har *filename;
- ixrect *pr;
-
- #ifdef STANDALONE
- ain(argc, argv, envp)
- #else
- crload_main(argc, argv, envp)
- #endif
- int argc;
- char **argv;
- char **envp;
- {
- register int i, j;
- int levels;
- char *fb; /* frame buffer */
-
- progname = strsave(argv[0]);
- parse_profile(&argc, argv, envp);
-
- fb = strsave("/dev/fb");
- while ((gc = getopt(argc, argv, "f:")) != EOF)
- switch (gc) {
- case 'f':
- fb = strsave(optarg);
- break;
- case '?':
- errflag++;
- break;
- }
-
- if (errflag)
- error((char *) 0, "Usage: %s: [infile ...]\n", progname);
-
- setup_greylevelmap();
-
- if (optind == argc || strcmp(argv[optind], "-") == 0)
- new_sc_load("", fb);
- else
- for (; optind < argc; optind++)
- new_sc_load(argv[optind], fb);
- }
-
- ew_sc_load(filename, fb)
- char *filename, *fb;
- {
- char colormapname[256];
- struct rasterfile rh;
- colormap_t colormap;
- FILE *fp, *fopen();
- int i, j, width, height, off_x, off_y;
- struct pixrect *line, *screen, *screen_temp;
- int sleep_time = 500;
-
- srand((int) time((time_t *) 0));
- if (filename[0]) {
- if ((fp = fopen(filename, "r")) == NULL) {
- warning("%s %s", PR_IO_ERR_INFILE, filename);
- return;
- }
- } else
- fp = stdin;
-
- screen = pr_open(fb);
- if (!screen)
- error("Couldn't open screen");
-
- if (screen->pr_depth > 1) {
- sleep_time = 0;
- if (pr_load_header(fp, &rh))
- error("pr_load_header failed for %s", (*filename) ? filename : "stdin");
- if (pr_load_colormap(fp, &rh, &colormap))
- error("pr_load_colormap failed for %s", (*filename) ? filename : "stdin");
- if (!(screen_temp = pr_load_image(fp, &rh, &colormap)))
- error("pr_load_image failed for %s", (*filename) ? filename : "stdin");
- if (colormap.length)
- pr_putcolormap(screen, 0, rh.ras_maplength / 3, colormap.map[0],
- colormap.map[1], colormap.map[2]);
- else
- pr_putcolormap(screen, 0, 256, greylevelmap, greylevelmap, greylevelmap);
-
- } else if ((screen_temp = pr_load(fp, NULL)) == NULL)
- error("Error reading rasterfile header for %s", (*filename) ? filename : "stdin");
-
- width = screen_temp->pr_size.x;
- height = screen_temp->pr_size.y;
- if (screen->pr_size.x > screen_temp->pr_size.x)
- off_x = (screen->pr_size.x - screen_temp->pr_size.x) / 2;
- if (screen->pr_size.y > screen_temp->pr_size.y)
- off_y = (screen->pr_size.y - screen_temp->pr_size.y) / 2;
-
- switch (rand() % 8) {
- case 0:
- for (j = height - 16; j > 0; j -= 16) {
- pr_rop(screen, off_x, j + off_y, width, height - j, PIX_SRC, screen_temp, 0, 0);
- usleep(sleep_time);
- }
- pr_rop(screen, off_x, off_y, width, height, PIX_SRC, screen_temp, 0, 0);
-
- break;
- case 1:
-
- for (j = 0; j < height; j += 32)
- for (i = 0; i < width; i += 32)
- pr_rop(screen, i + off_x, j + off_y, 16, 16, PIX_SRC, screen_temp, i, j);
- for (j = 16; j < height; j += 32)
- for (i = 16; i < width; i += 32)
- pr_rop(screen, i + off_x, j + off_y, 16, 16, PIX_SRC, screen_temp, i, j);
- for (j = 16; j < height; j += 32)
- for (i = 0; i < width; i += 32)
- pr_rop(screen, i + off_x, j + off_y, 16, 16, PIX_SRC, screen_temp, i, j);
- for (j = 0; j < height; j += 32)
- for (i = 16; i < width; i += 32)
- pr_rop(screen, i + off_x, j + off_y, 16, 16, PIX_SRC, screen_temp, i, j);
- break;
-
- case 2:
- for (j = height - 16; j > 0; j -= 16) {
-
- pr_rop(screen, off_x, off_y, width, height - j, PIX_SRC, screen_temp, 0, j);
- usleep(sleep_time);
- }
- pr_rop(screen, off_x, off_y, width, height, PIX_SRC, screen_temp, 0, 0);
- break;
-
- case 3:
- for (j = height - 16; j > 0; j -= 16) {
-
- pr_rop(screen, off_x, j + off_y, width / 2, height - j, PIX_SRC, screen_temp, 0, 0);
- pr_rop(screen, off_x + width / 2, off_y, width / 2, height - j, PIX_SRC, screen_temp, width / 2, j);
- usleep(sleep_time);
- }
- pr_rop(screen, off_x, off_y, width, height, PIX_SRC, screen_temp, 0, 0);
- break;
- case 4:
- for (j = height - 16; j > 0; j -= 16) {
-
- pr_rop(screen, off_x + width / 2, j + off_y, width / 2, height - j, PIX_SRC, screen_temp, width / 2, 0);
- pr_rop(screen, off_x, off_y, width / 2, height - j, PIX_SRC, screen_temp, 0, j);
- usleep(sleep_time);
- }
- pr_rop(screen, off_x, off_y, width, height, PIX_SRC, screen_temp, 0, 0);
- break;
-
- case 5:
- for (j = height - 16; j > 0; j -= 16) {
-
- pr_rop(screen, off_x, off_y, width / 4, height - j, PIX_SRC, screen_temp, 0, j);
- pr_rop(screen, off_x + width / 4, j + off_y, width / 4 + 2, height - j, PIX_SRC, screen_temp, width / 4, 0);
- pr_rop(screen, off_x + width / 4 * 3, j + off_y, width / 4, height - j, PIX_SRC, screen_temp, width / 4 * 3, 0);
- pr_rop(screen, off_x + width / 2, off_y, width / 4, height - j, PIX_SRC, screen_temp, width / 2, j);
- usleep(sleep_time);
- }
- pr_rop(screen, off_x, off_y, width, height, PIX_SRC, screen_temp, 0, 0);
- break;
- case 6:
- for (j = height - 16; j > 0; j -= 16) {
-
- pr_rop(screen, off_x, off_y, width / 4, height - j, PIX_SRC, screen_temp, 0, j);
- pr_rop(screen, off_x + width / 4, j + off_y, width / 4, height - j, PIX_SRC, screen_temp, width / 4, 0);
- pr_rop(screen, off_x + width / 2, j + off_y, width / 4, height - j, PIX_SRC, screen_temp, width / 2, 0);
- pr_rop(screen, off_x + width / 4 * 3, off_y, width / 4, height - j, PIX_SRC, screen_temp, width / 4 * 3, j);
- usleep(sleep_time);
- }
- pr_rop(screen, off_x, off_y, width, height, PIX_SRC, screen_temp, 0, 0);
- break;
-
- case 7:
- for (j = 16; j < width / 2; j += 16) {
-
- pr_rop(screen, off_x + width / 2 - j, off_y, j, height, PIX_SRC, screen_temp, 0, 0);
- pr_rop(screen, off_x + width / 2, off_y, j, height, PIX_SRC, screen_temp, width - j, 0);
- usleep(sleep_time);
- }
- pr_rop(screen, off_x, off_y, width, height, PIX_SRC, screen_temp, 0, 0);
- break;
- }
- pr_destroy(screen_temp);
- pr_close(screen);
- fclose(fp);
- }
-